
/**
 * Menu
 */

import { request } from "@/utils/service"
import type * as Menu from "./types/menu"

/** 
 * 用户根据权限获取可用菜单列表
 * 使用 用户登录的 token 获取用户有权限的菜单
 * 返回结构必须按照这个结构体形式处理，或根据
 */
export function getUserMenus(data: Menu.UserManusRequestData) {
  return request<Menu.MenuListResponseData>({
    url: "/api/admin/cmn/menu/getUserMenus",
    method: "get",
    data,
  })
}

/** 获取所有菜单 */
export function queryMenus(data: Menu.AllMenusRequestData) {
  return request<Menu.MenuListResponseData>({
    url: "/api/admin/cmn/menu/queryMenus",
    method: "post",
    data
  })
}
/** 菜单详情 */
export function getMenuDetail(id: string) {
  return request<Menu.MenuDetailResponseData>({
    url: `api/admin/cmn/menu/getMenuDetail/${id}`,
    method: "get"
  })
}

/** 批量添加菜单 */
export function saveBatch(data: Array<Menu.MenuInfoRequestData>) {
  return request({
    url: "api/admin/cmn/menu/saveBatch",
    method: "post",
    data
  })
}
/** 添加菜单 */
export function addMenu(data: Menu.MenuInfoRequestData) {
  return request({
    url: "api/admin/cmn/menu/addMenu",
    method: "post",
    data
  })
}
/** 修改菜单 */
export function updateMenu(data: Menu.MenuInfoRequestData) {
  return request({
    url: "api/admin/cmn/menu/updateMenu",
    method: "post",
    data
  })
}

/** 删除菜单 */
export function removeMenu(data: Menu.MenuInfoRequestData) {
  return request({
    url: "api/admin/cmn/menu/removeMenu",
    method: "post",
    data
  })
}
